angular.module('todo', ['ionic', 'ngCordova'])
    .controller('TodoCtrl', function ($scope, $ionicPopup, $cordovaBarcodeScanner) {
        $scope.tasks = [
            {title: '菜鸟教程'},
            {title: 'www.runoob.com'},
            {title: '菜鸟教程'},
            {title: 'www.runoob.com'}
        ];

        $scope.addBtn = function() {
            /**
            var alertPopup = $ionicPopup.alert({
                title: 'Don\'t eat that!',
                template: 'It might taste good'
            });
            alertPopup.then(function(res) {
                console.log('Thank you for not eating my delicious ice cream cone');
            });
             */

            $cordovaBarcodeScanner.scan().then(function(imageData) {
                alert(imageData.text);
                console.log(imageData.format);
                console.log(imageData.cancelled);
            }, function(error) {
                console.log('An error happened ->' + error);
            })
        };
    });